#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    string changeStr(string& s)
    {
        string ret = "";
        for (auto ch : s)
        {
            if (ch != '#') ret += ch;
            else
            {
                if (!ret.empty())
                    ret.pop_back();
            }
        }
        return ret;
    }
    bool backspaceCompare(string s, string t) {
        return changeStr(s) == changeStr(t);
    }
};